export async function asyncMap<T, R>(arr: Array<T>, func: (item: T, index: number) => R | Promise<R>): Promise<R[]> {
	return Promise.all(arr.map(func));
}

export async function asyncFlatMap<T, R>(
	arr: Array<T>,
	func: (item: T, index: number) => R | R[] | Promise<R | R[]>
): Promise<R[]> {
	const result = await Promise.all(arr.map(func));
	return result.flatMap((v) => v);
}
